package routes

import (
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	_ "system-admin/docs"
	gin2 "system-admin/internal/controller/middleWare"
	"system-admin/internal/routes/blogRouter"
	"system-admin/internal/routes/userRouter"
)

func RunRouter() {
	//1.创建引擎服务
	router := gin.Default()
	router.Use(gin2.Cors())

	router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	//加载定义路由
	userRouter.InitUserRouter(router)
	blogRouter.InitBlogRouter(router)

	//启动服务器端口
	router.Run(":" + viper.GetString("port"))
}
